<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>报名</title>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="keywords" name="keywords" content="" />
    <meta http-equiv="description" name="description" content="" />
    <link href="css/ydui.css" rel="stylesheet" />
    <link href="https://cdn.bootcss.com/Swiper/4.2.0/css/swiper.min.css" rel="stylesheet">
    <script src="js/ydui.flexible.js"></script>
	<link rel="stylesheet" type="text/css" href="css/all.css"/>
    
</head>
<body ms-controller="mobileplandetail">
<section class="g-flexview">
    <header class="m-navbar">
  		<a onclick="history.back()" class="navbar-item"><i class="back-ico"></i></a>    	
        <div class="navbar-center"><span class="navbar-title">报名</span></div>
    </header>
    <section class="g-scrollview">
		<div class="m-cell demo-small-pitch">
            <div class="cell-item">
                <div class="cell-left">姓名：</div>
                <div class="cell-right"><input type="text" ms-duplex="@new.personName" class="cell-input" placeholder="请输入您的姓名" autocomplete="off"></div>
            </div>
            <div class="cell-item">
                <div class="cell-left">电话：</div>
                <div class="cell-right"><input type="number" ms-duplex="@new.personPhone"  class="cell-input" oninput="if(value.length>11)value=value.slice(0,11)" placeholder="请输入您电话" autocomplete="off"></div>
            </div>
            <div class="cell-item">
                <div class="cell-left">身份证号：</div>
                <div class="cell-right"><input type="text" ms-duplex="@new.personCard"  class="cell-input" placeholder="请输入身份证号" autocomplete="off"></div>
            </div>    
            <div class="cell-item">
            	<div class="cell-left">学校：</div>
				<label class="cell-right cell-arrow">
                    <select class="cell-select"  ms-duplex="@new.schoolId">
                        <option value="">请选择</option>
                        <option ms-for="el in @schooldata" ms-attr="{'value':el.id}">{{el.name}}</option>
                    </select>
                </label>            	
            </div>
        </div>
    </section>
    <button class="btn-block btn-primary" ms-on-click="@post()">
       	报名
    </button>	
</section>
    <script src="https://cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
    <script src="js/ydui.js"></script>
	<script src="https://cdn.bootcss.com/avalon.js/2.2.7/avalon.min.js"></script>
	<script src="../js/all.js" type="text/javascript" charset="utf-8"></script>
	<script src="https://cdn.bootcss.com/Swiper/4.2.0/js/swiper.min.js"></script>
<script>	
    var model=avalon.define({
    	$id:'mobileplandetail',
    	id:ComFunJS.getQueryString('id'),
    	datainfo:{},
    	schooldata:[],	
   		getschool:function(){
   			ComFunJS.getJSON(ComFunJS.APIURL('school/querySchools'),function(r){
   				model.schooldata=r.data.schoolValue
   			})
   		},
    	new:{schoolId:"",personName:"",personPhone:"",personCard:""},
   		post:function(){
			if(model.new.personName==""){
            YDUI.dialog.toast('姓名不能为空！', 'error', 1000);
            	 return 
			}	
			if(model.new.personPhone==""){
 			YDUI.dialog.toast('电话不能为空！', 'error', 1000);					
            	 return 
			}					
			if(model.new.personCard==""){
			 YDUI.dialog.toast('身份证不能为空！', 'error', 1000);				
            	 return 
			}	
			ComFunJS.postJSON(ComFunJS.APIURL('plan/team/save'),{schoolId:model.new.schoolId,personName:model.new.personName,personPhone:model.new.personPhone,creatorPlanId:model.id,personCard:model.new.personCard},function(r){
				if(r.code==200){
					YDUI.dialog.toast('报名成功', 'success', 1000,function(){
						window.location.href='planlist.html'
					});
				}else{
					YDUI.dialog.toast(r.msg, 'error', 1000);		
				}				
			})
   		},	
    })
    avalon.ready(function(){
    	model.getschool()
    })
    </script>
</body>
</html>
